package tour.spring.bc.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
public class Tour {

	private Long id;
	private Date dateFrom;
	private Date dateTo;
	private Hotel hotel;
	private double basePrice;
	private int placeQuantity;
	private List<Reservation> reservations;
	private String description;
	
	@Column(name="date_from")
	public Date getDateFrom() {
		return dateFrom;
	}
	public void setDateFrom(Date dateFrom) {
		this.dateFrom = dateFrom;
	}
	
	@Column(name="date_to")
	public Date getDateTo() {
		return dateTo;
	}
	public void setDateTo(Date dateTo) {
		this.dateTo = dateTo;
	}
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name="hotel_id")
	public Hotel getHotel() {
		return hotel;
	}
	public void setHotel(Hotel hotel) {
		this.hotel = hotel;
	}
	
	public int getPlaceQuantity() {
		return placeQuantity;
	}
	public void setPlaceQuantity(int placeQuantity) {
		this.placeQuantity = placeQuantity;
	}
	
	@Column(name="base_price")
	public double getBasePrice() {
		return basePrice;
	}

	public void setBasePrice(double basePrice) {
		this.basePrice = basePrice;
	}

	@OneToMany(mappedBy="tour")
	public List<Reservation> getReservations() {
		return reservations;
	}
	
	public void setReservations(List<Reservation> reservations) {
		this.reservations = reservations;
	}
	
	@Column
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}

	@Column
	@Id
	@SequenceGenerator(name="tour_seq", sequenceName="tour_seq")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="tour_seq")
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
}
